
/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"F37D2C88-CD26-4379-B7BF-A3895AB847DB"}
 */
function agregar(event) {
	hoteles_medios_pago_to_hoteles_medios_pago_dtl.newRecord()
}

/**
 * @properties={typeid:24,uuid:"F1BBECAF-D5B4-4B1C-A1FE-6BBD97D84AC1"}
 */
function guardar() {
	var $cant = hoteles_medios_pago_to_hoteles_medios_pago_dtl.getSize()
	var i = 1
	while (i <= $cant)
	{
		var $rcd = hoteles_medios_pago_to_hoteles_medios_pago_dtl.getRecord(i)
		
		if ($rcd.cuotas == 0)
		{
			hoteles_medios_pago_to_hoteles_medios_pago_dtl.setSelectedIndex(i)
			hoteles_medios_pago_to_hoteles_medios_pago_dtl.deleteRecord()
			$cant--
		}
		else
		{
			i++
		}
	}
	if (hoteles_medios_pago_to_hoteles_medios_pago_dtl.getSize() == 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso','Por favor, ingrese una forma de pago válida','OK')
		hoteles_medios_pago_to_hoteles_medios_pago_dtl.newRecord()
		hoteles_medios_pago_to_hoteles_medios_pago_dtl.cuotas = 1
		hoteles_medios_pago_to_hoteles_medios_pago_dtl.porc_interes = 0
		return false
	}
	if (databaseManager.saveData() == true)
	{
		globals.llenarVlHoteles()
		globals.DIALOGS.showInfoDialog('Aviso','Datos modificados con éxito','OK')
		return true
	}
	else
	{
		globals.DIALOGS.showWarningDialog('Aviso','Ocurrio un error al grabar. Inténtelo nuevamente', 'OK')
		return false
	}
}

/**
 * @properties={typeid:24,uuid:"B309C61B-A1F8-4DA9-BD12-3B7DB74F65D9"}
 */
function cancelar() {
	databaseManager.revertEditedRecords()
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"9A0AF6FF-0C46-4902-A634-B6768A7C4DF2"}
 */
function onShow(firstShow, event) {
	databaseManager.setAutoSave(false)
}

/**
 * Handle hide window.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"39DAD832-B41C-46A3-B959-B0E988637D97"}
 */
function onHide(event) {
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	return true
}
